﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:toms="urn:TomsToolbox"
                    xmlns:styles="clr-namespace:tomenglertde.ResXManager.Styles">
  <Style x:Key="{x:Static styles:ResourceKeys.CheckBoxStyle}" TargetType="{x:Type CheckBox}">
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
    <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Padding" Value="4,1,0,0" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="CheckBox">
          <Grid Background="Transparent">
            <BulletDecorator Background="Transparent" SnapsToDevicePixels="True">
              <BulletDecorator.Bullet>
                <Border Width="13" Height="13" BorderThickness="1"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}">
                  <Grid>
                    <Path x:Name="CheckMark" Stretch="Fill" Margin="1"
                          Data="M7,0 3,5 1,3 0,4 3,7 9,0 z"
                          Fill="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                          Visibility="Hidden" UseLayoutRounding="False" />
                    <Rectangle x:Name="IndeterminateCheckMark" Width="7" Height="7"
                               Visibility="Hidden"
                               Fill="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
                  </Grid>
                </Border>
              </BulletDecorator.Bullet>
              <Grid Margin="{TemplateBinding Padding}"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                <ContentPresenter x:Name="Content" RecognizesAccessKey="True" />
                <Rectangle x:Name="FocusVisual" StrokeThickness="1" Visibility="Hidden"
                           Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                           StrokeDashArray="1 2" Margin="-2,-1" SnapsToDevicePixels="True" />
              </Grid>
            </BulletDecorator>
          </Grid>
          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True"/>
                <Condition Property="IsEnabled" Value="True"/>
              </MultiTrigger.Conditions>
              <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" />
            </MultiTrigger>
            <MultiDataTrigger>
              <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding IsKeyboardFocused, RelativeSource={RelativeSource Self}}" Value="True" />
                <Condition Binding="{Binding IsFocusVisualVisible, Source={x:Static toms:KeyboardNavigation.Current}}" Value="True" />
              </MultiDataTrigger.Conditions>
              <Setter Property="Visibility" TargetName="FocusVisual" Value="Visible" />
            </MultiDataTrigger>
            <Trigger Property="IsPressed" Value="True">
              <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter TargetName="CheckMark" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsChecked" Value="{x:Null}">
              <Setter TargetName="IndeterminateCheckMark" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Background" Value="{DynamicResource {x:Static styles:ResourceKeys.DisabledBrush}}" />
              <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="CheckBox" x:Key="{x:Static styles:ResourceKeys.DataGridCheckBoxEditingElementStyle}" BasedOn="{StaticResource {x:Static styles:ResourceKeys.CheckBoxStyle}}">
    <Setter Property="HorizontalAlignment" Value="Center" />
    <Setter Property="VerticalAlignment" Value="Center" />
  </Style>

  <Style TargetType="CheckBox" x:Key="{x:Static styles:ResourceKeys.DataGridCheckBoxElementStyle}" BasedOn="{StaticResource {x:Static styles:ResourceKeys.CheckBoxStyle}}">
    <Setter Property="HorizontalAlignment" Value="Center" />
    <Setter Property="VerticalAlignment" Value="Center" />
    <Setter Property="IsHitTestVisible" Value="False" />
    <Setter Property="Focusable" Value="False" />
  </Style>

</ResourceDictionary>